package cn.fu.ssh.dao.impl;

import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import cn.fu.ssh.dao.ILeaveBillDao;
import cn.fu.ssh.domain.LeaveBill;

public class LeaveBillDaoImpl extends HibernateDaoSupport implements ILeaveBillDao {

	/**查询所有的请假单列表*/
	public List<LeaveBill> findLeaveBillList() {
		List<LeaveBill> list = this.getHibernateTemplate().find("from LeaveBill");
		return list;
	}
	
	/**执行保存*/
	public void save(LeaveBill leaveBill) {
		this.getHibernateTemplate().save(leaveBill);
	}
	
	/**使用主键ID，查询请假申请单的对象*/
	public LeaveBill findLeaveBillByID(Long id) {
		LeaveBill leaveBill = this.getHibernateTemplate().get(LeaveBill.class, id);
		return leaveBill;
	}
	
	/**执行更新，对象中存放主键ID的值*/
	public void update(LeaveBill leaveBill) {
		this.getHibernateTemplate().update(leaveBill);
	}
	
	/**使用ID，删除请假单*/
	public void deleteLeaveBillByID(Long id) {
		//先使用ID查询Object对象
		LeaveBill leaveBill = this.findLeaveBillByID(id);
		this.getHibernateTemplate().delete(leaveBill);
	}
}
